<?php

namespace app\screen\controller\railway;

use app\BaseController;

use app\common\model\broadcast\DeviceRod;
use app\common\model\broadcast\IpBroadcast;
use app\common\model\broadcast\IpBroadcastFile;
use app\common\model\haikang\HkConsumerMsg;
use app\common\model\haikang\HkConsumerMsgWeek;
use app\common\model\haikang\HkEventType;
use app\common\model\haikang\VideoPlayback;
use app\common\model\work_area\HkDeviceSerial;
use app\common\model\work_area\WorkArea;
use app\common\model\work_area\WorkAreaStand;
use app\common\service\broadcast\IpBroadcastService;
use hg\apidoc\annotation as Apidoc;
use app\common\model\work_area\WorkAreaStandVoice;

/**
 * @Apidoc\Title("工点相关")
 */
class Stand extends BaseController
{

    /**
     * @Apidoc\Title("工程详情")
     * @Apidoc\Url("/screen/railway.Stand/standInfo")
     * @Apidoc\Param("id",type="int",require=true, desc="工点ID")
     * @Apidoc\Method("POST")
     * @Apidoc\Returned("data", type="object", desc="对象信息",
     *    @Apidoc\Returned("id", type="string", desc="工点ID"),
     *    @Apidoc\Returned("name", type="string", desc="工点名称"),
     *    @Apidoc\Returned("addr", type="string", desc="地址"),
     *    @Apidoc\Returned("proj_name", type="string", desc="项目描述"),
     *    @Apidoc\Returned("responsible", type="string", desc="安全负责人"),
     *    @Apidoc\Returned("responsible_phone", type="string", desc="安全负责人手机号"),
     *    @Apidoc\Returned("work_unit", type="string", desc="施工责任单位"),
     *    @Apidoc\Returned("supervise", type="string", desc="上级监管单位"),
     *    @Apidoc\Returned("build_unit", type="string", desc="建设单位"),
     *    @Apidoc\Returned("st_line", type="string", desc="涉铁线路"),
     *    @Apidoc\Returned("finish_time", type="string", desc="预估完工时间"),
     *    @Apidoc\Returned("risk_level", type="string", desc="风险等级"),
     *    @Apidoc\Returned("coordinate", type="string", desc="坐标位置"),
     *    @Apidoc\Returned("yield_time", type="string", desc="生产开始时间"),
     * )
     */
    public function standInfo()
    {
        try {
            $param = $this->request->param();
            Validate([
                'id|工点id' => 'require',
            ])->check($param);
            $info = WorkAreaStand::where(['id' => $param['id']])->find();
        } catch (\Exception $e) {
            // 验证失败 输出错误信息
            return ajaxJson(0, $e->getMessage());
        }
        return ajaxJson(1, '成功', $info);
    }

    /**
     * @Apidoc\Title("设备状态")
     * @Apidoc\Url("/screen/railway.Stand/deviceInfo")
     * @Apidoc\Param("id",type="int",require=true, desc="工点ID，传0获取全部")
     * @Apidoc\Method("POST")
     * @Apidoc\Returned("data", type="object", desc="对象信息",
     *    @Apidoc\Returned("on_line_device_rod_num", type="int", desc="在线装置数量"),
     *    @Apidoc\Returned("camera_num", type="int", desc="摄像头数量"),
     *    @Apidoc\Returned("radar_num", type="int", desc="雷达数量"),
     *    @Apidoc\Returned("broadcast", type="int", desc="广播数量"),
     *    @Apidoc\Returned("line_num", type="int", desc="线路数量"),
     *    @Apidoc\Returned("stand_num", type="int", desc="涉铁工程"),
     *    @Apidoc\Returned("device_rod_num", type="int", desc="装置总数量"),
     *    @Apidoc\Returned("alarm_num", type="int", desc="累计防入侵"),
     *    @Apidoc\Returned("illegal_homework", type="int", desc="违法作业数量"),
     *    @Apidoc\Returned("stop_num", type="int", desc="停工整改数量"),
     * )
     */
    public function deviceInfo()
    {
        try {
            $param = $this->request->param();
            $line_num = 0;
            $stand_num = 0;
            $where = [];
            //查询指定工点
            if ($param['id'] > 0) {
                $where = ['work_area_stand_id' => $param['id']];
            } else {
                $line_num = WorkArea::count('*');
                $stand_num = WorkAreaStand::count('*');
            }
            $on_line_device_rod_num = DeviceRod::where($where)->where(['is_on_line' => 1])->count('*');
            $camera_num = HkDeviceSerial::where($where)->count('*');
            $radar_num = DeviceRod::where($where)->sum('radar_num');
            $broadcast = IpBroadcast::where($where)->count('*');
            $device_rod_num = DeviceRod::where($where)->count('*');
            $alarm_num = HkConsumerMsg::where($where)->count('*');
            $illegal_homework = 0;
            $stop_num = 0;
            $data = [
                'on_line_device_rod_num' => $on_line_device_rod_num,
                'camera_num' => $camera_num,
                'radar_num' => $radar_num,
                'broadcast' => $broadcast,
                'line_num' => $line_num,
                'stand_num' => $stand_num,
                'device_rod_num' => $device_rod_num,
                'alarm_num' => $alarm_num,
                'illegal_homework' => $illegal_homework,
                'stop_num' => $stop_num,
            ];
        } catch (\Exception $e) {
            // 验证失败 输出错误信息
            return ajaxJson(0, $e->getMessage());
        }
        return ajaxJson(1, '成功', $data);
    }


    /**
     * @Apidoc\Title("实时预警")
     * @Apidoc\Url("/screen/railway.Stand/realTimeAlarm")
     * @Apidoc\Param("id",type="int",require=true, desc="工点ID，传0获取全部")
     * @Apidoc\Param("page", type="int", desc="第几页默认第1页")
     * @Apidoc\Param("page_size", type="int", desc="每页几条默认10条")
     * @Apidoc\Method("POST")
     * @Apidoc\Returned("data", type="object", desc="对象信息",
     *    @Apidoc\Returned("id", type="int", desc="报警ID"),
     *    @Apidoc\Returned("msg_name", type="string", desc="报警类型"),
     *    @Apidoc\Returned("create_time", type="string", desc="报警时间"),
     *    @Apidoc\Returned("channel_no", type="string", desc="摄像头通道号"),
     *    @Apidoc\Returned("device_serial", type="string", desc="摄像头序列号"),
     *    @Apidoc\Returned("bname", type="string", desc="装置名称"),
     *    @Apidoc\Returned("cname", type="string", desc="工点名称"),
     *    @Apidoc\Returned("st_line", type="string", desc="涉铁线路"),
     *    @Apidoc\Returned("work_area_stand_id", type="string", desc="站点ID"),
     *    @Apidoc\Returned("file_url", type="string", desc="视频回放地址"),
     * )
     */
    public function realTimeAlarm()
    {
        try {
            $param = $this->request->param();
            $page_size = empty($param['page_size']) ? 10 : $param['page_size'];
            $where = [];
            //指定站点查询
            if ($param['id'] > 0) {
                $where = ['a.work_area_stand_id' => $param['id']];
            }
            $list_ = HkConsumerMsgWeek::alias("a")
                ->join("device_rod b", "b.id = a.device_rod_id", 'left')//装置
                ->join("work_area_stand c", "c.id = a.work_area_stand_id", 'left')//站点
                ->where($where)
                ->where(['a.is_show' => 1])
                ->order("a.create_time DESC")
                ->field([
                    'a.id', 'a.msg_name', 'a.create_time', 'a.yj_data_id', 'a.image_url', 'a.work_area_stand_id', 'a.channel_no', 'a.device_serial_id', 'a.device_serial', 'a.device_name',
                    'b.name bname',
                    'c.name cname'
                ])
                ->paginate($page_size)
                ->toArray();
            $list = $list_ ['data'];
            foreach ($list as $key => $val) {
                //获取涉铁线路
                $list[$key]['st_line'] = WorkArea::where('id', 'IN', function ($query) use ($val) {
                    $query->name('work_area_stand')->where('id', $val['work_area_stand_id'])->field('id');
                })->value('name');
                $list[$key] ['file_url'] = VideoPlayback::where(['yj_data_id' => $val['yj_data_id']])->value('file_url');
                $list[$key] ['rtp_url_whole'] = HkDeviceSerial::where(['id' => $val['device_serial_id']])->value('rtp_url_whole');
                $list[$key] ['msg_name'] = $val['msg_name'] == '雷达侦测' ? '雷达侦测' : 'AI检测';
                $path = WorkAreaStandVoice::where(['event_type' => $val['msg_name'], 'hk_device_serial_id' => $val['device_serial_id']])->value('file');
                if ($path) {
                    $list[$key]['play_url'] = 'http://ai.admin.lgsid.com/' . $path;
                }
            }
        } catch (\Exception $e) {
            // 验证失败 输出错误信息
            return ajaxJson(0, $e->getMessage());
        }
        return ajaxJson(1, '成功', [
            'list' => $list,
            'total' => $list_['total'],
            'page_size' => $page_size
        ]);
    }


    /**
     * @Apidoc\Title("报警统计")
     * @Apidoc\Url("/screen/railway.Stand/alarmStatistics")
     * @Apidoc\Param("id",type="int",require=true, desc="工点ID，传0获取全部")
     * @Apidoc\Param("start_time", type="string", desc="开始时间")
     * @Apidoc\Param("end_time", type="string", desc="结束时间")
     * @Apidoc\Method("POST")
     * @Apidoc\Returned("data", type="object", desc="对象信息",
     *    @Apidoc\Returned("date", type="string", desc="日期"),
     *    @Apidoc\Returned("type", type="string", desc="报警类型"),
     *    @Apidoc\Returned("count", type="int", desc="报警数量")
     * )
     */
    public function alarmStatistics()
    {
        try {
            $param = $this->request->param();
            Validate([
                'start_time|开始时间' => 'require',
                'end_time|结束时间' => 'require',
            ])->check($param);
            $hk_event_type = ['雷达侦测', 'AI检测'];
            $day = generateDateRangeArray($param['start_time'], $param['end_time']);
            $data = [];
            foreach ($day as $key => $val) {
                $data[$key]['date'] = $val;
                foreach ($hk_event_type as $k => $v) {
                    $where = $v == '雷达侦测' ? "msg_name = '雷达侦测'" : "msg_name <> '雷达侦测'";
                    $data[$key]['type'][$k] = [
                        'type' => $v,
                        'count' => HkConsumerMsg::where($param['id'] > 0 ? ['work_area_stand_id' => $param['id']] : [])
                            ->whereDay('create_time', $val)
                            ->where($where)
                            ->count('*'),
                    ];
                    unset($where);
                }
            }
        } catch (\Exception $e) {
            // 验证失败 输出错误信息
            return ajaxJson(0, $e->getMessage());
        }
        return ajaxJson(1, '成功', ['list' => $data, 'event_type' => $hk_event_type]);
    }


    /**
     * @Apidoc\Title("事件类型列表")
     * @Apidoc\Url("/screen/railway.Stand/eventTypeList")
     * @Apidoc\Method("POST")
     * @Apidoc\Returned("data", type="object", desc="返回说明")
     */
    public function eventTypeList()
    {
        //只获取下面数组事件
        $event_arr_id = HkEventType::$event_arr_id;
        $hk_event_type = HkEventType::where(['id' => $event_arr_id])->column('remarks');
        return ajaxJson(1, '成功', $hk_event_type);
    }

    /**
     * @Apidoc\Title("线路列表树结构")
     * @Apidoc\Url("/screen/railway.Stand/workAreaList")
     * @Apidoc\Method("POST")
     * @Apidoc\Returned("data", type="object", desc="对象信息",
     *    @Apidoc\Returned("id", type="int", desc="id"),
     *    @Apidoc\Returned("name", type="string", desc="路线名称"),
     *    @Apidoc\Returned("abstract", type="string", desc="摘要"),
     * )
     */
    public function workAreaList()
    {
        $list = WorkArea::where(['is_use' => 1])->field(['id', 'name label', 'abstract'])->select()->toArray();
        foreach ($list as $key => $val) {
            //站点
            $work_area_stand = WorkAreaStand::where(['work_area_id' => $val['id']])->where(['is_use' => 1])->field(['id', 'name label', 'proj_name'])->select()->toArray();
            $list[$key]['children'] = $work_area_stand;
            $list[$key]['type'] = 1;
            foreach ($work_area_stand as $kk => $vv) {
                //查询装置列表
                $device_rod = DeviceRod::where(['work_area_stand_id' => $vv['id']])->field(['id', 'name label', 'work_area_stand_id'])->select()->toArray();
                $list[$key]['children'][$kk]['children'] = $device_rod;
                $list[$key]['children'][$kk]['type'] = 2;
                foreach ($device_rod as $k => $v) {
                    //查询摄像头
                    $hk_device_serial = HkDeviceSerial::where(['device_rod_id' => $v['id']])->field(['id', 'device_serial', 'work_area_stand_id', 'channel_no', 'rtp_url_whole', 'name label', '4 as type'])->select()->toArray();
                    $list[$key]['children'][$kk]['children'][$k]['children'] = $hk_device_serial;
                    $list[$key]['children'][$kk]['children'][$k]['type'] = 3;
                    unset($hk_device_serial);
                }
                unset($device_rod);
            }
            unset($work_area_stand);
        }
        return ajaxJson(1, '成功', $list);
    }

    /**
     * @Apidoc\Title("装置列表树结构")
     * @Apidoc\Url("/screen/railway.Stand/deviceRodList")
     * @Apidoc\Param("id",type="int",require=true, desc="工点ID")
     * @Apidoc\Method("POST")
     * @Apidoc\Returned("data", type="object", desc="对象信息",
     *    @Apidoc\Returned("id", type="int", desc="id"),
     *    @Apidoc\Returned("name", type="string", desc="装置名称"),
     *    @Apidoc\Returned("rtp_url_whole", type="string", desc="流媒体全地址"),
     * )
     */
    public function deviceRodList()
    {
        $param = $this->request->param();
        $list = WorkArea::where(['is_use' => 1])
            ->where('id', 'IN', function ($query) use ($param) {
                $query->name('work_area_stand')->where('id', $param['id'])->field('work_area_id');
            })
            ->field(['id', 'name label', 'abstract'])->select()->toArray();
        foreach ($list as $key => $val) {
            //站点
            $work_area_stand = WorkAreaStand::where(['work_area_id' => $val['id']])->where(['is_use' => 1])->field(['id', 'name label', 'proj_name'])->select()->toArray();
            $list[$key]['children'] = $work_area_stand;
            $list[$key]['type'] = 1;
            foreach ($work_area_stand as $kk => $vv) {
                //查询装置列表
                $device_rod = DeviceRod::where(['work_area_stand_id' => $vv['id']])->field(['id', 'name label', 'work_area_stand_id'])->select()->toArray();
                $list[$key]['children'][$kk]['children'] = $device_rod;
                $list[$key]['children'][$kk]['type'] = 2;
                foreach ($device_rod as $k => $v) {
                    //查询摄像头
                    $hk_device_serial = HkDeviceSerial::where(['device_rod_id' => $v['id']])->field(['id', 'device_serial', 'work_area_stand_id', 'channel_no', 'rtp_url_whole', 'name label', '4 as type'])->select()->toArray();
                    $list[$key]['children'][$kk]['children'][$k]['children'] = $hk_device_serial;
                    $list[$key]['children'][$kk]['children'][$k]['type'] = 3;
                    unset($hk_device_serial);
                }
                unset($device_rod);
            }
            unset($work_area_stand);
        }
        return ajaxJson(1, '成功', $list);
    }

    /**
     * @Apidoc\Title("报警日志列表")
     * @Apidoc\Url("/screen/railway.Stand/alarmLog")
     * @Apidoc\Param("work_area_stand_id",type="int",require=true, desc="工点ID，传0获取全部")
     * @Apidoc\Param("work_area_id",type="int",require=true, desc="线路ID，传0获取全部")
     * @Apidoc\Param("device_rod_id",type="int",require=true, desc="装置ID，传0获取全部")
     * @Apidoc\Param("is_show",type="int",require=true, desc="1异物入侵 2作废事件")
     * @Apidoc\Param("device_serial_id",type="array",require=true, desc="摄像头id")
     * @Apidoc\Param("keyword_time", type="array", desc="数组0开始 1结束")
     * @Apidoc\Param("page", type="int", desc="第几页默认第1页")
     * @Apidoc\Param("page_size", type="int", desc="每页几条默认10条")
     * @Apidoc\Param("is_export", type="int", desc="1导出 默认传0")
     * @Apidoc\Method("POST")
     * @Apidoc\Returned("data", type="object", desc="对象信息",
     *    @Apidoc\Returned("id", type="int", desc="报警ID"),
     *    @Apidoc\Returned("msg_name", type="string", desc="报警类型"),
     *    @Apidoc\Returned("create_time", type="string", desc="报警时间"),
     *    @Apidoc\Returned("channel_no", type="string", desc="摄像头通道号"),
     *    @Apidoc\Returned("device_serial", type="string", desc="摄像头序列号"),
     *    @Apidoc\Returned("bname", type="string", desc="装置名称"),
     *    @Apidoc\Returned("cname", type="string", desc="工点名称"),
     *    @Apidoc\Returned("st_line", type="string", desc="涉铁线路"),
     *    @Apidoc\Returned("file_url", type="string", desc="视频回放地址"),
     *    @Apidoc\Returned("work_area_stand_id", type="string", desc="站点ID"),
     * )
     */
    public function alarmLog()
    {
        try {
            $param = $this->request->param();
            $page_size = empty($param['page_size']) ? 10 : $param['page_size'];
            $where = [];

            $where[] = ['a.is_show', '=', $param['is_show']];
            //指定站点查询
            if (!empty($param['work_area_stand_id'])) {
                $where[] = ['a.work_area_stand_id', '=', $param['work_area_stand_id']];
            }
            //指定工区线路查询
            if (!empty($param['work_area_id'])) {
                $where[] = ['a.work_area_stand_id', 'IN', function ($query) use ($param) {
                    $query->name('work_area_stand')->where('work_area_id', $param['work_area_id'])->field('id');
                }];
            }
            //事件查询
            if (!empty($param['msg_name'])) {
                $where[] = ['a.msg_name', '=', $param['msg_name']];
            }
            //装置查询
            if (!empty($param['device_rod_id'])) {
                $where[] = ['a.device_rod_id', '=', $param['device_rod_id']];
            }
            //摄像头查询
            if (!empty($param['device_serial_id'])) {
                $where[] = ['a.device_serial_id', 'in', $param['device_serial_id']];
            }
            //时间查询
            if (!empty($param['keyword_time'])) {
                $time = "a.create_time";//查询时间字段
                $timeWhere = timeWhere($param['keyword_time'][0], $param['keyword_time'][1]);
                $where[] = [$time, '>=', $timeWhere[0]];
                $where[] = [$time, '<=', $timeWhere[1] + 86399];
            }
            $list_ = HkConsumerMsg::alias("a")
                ->join("device_rod b", "b.id = a.device_rod_id", 'left')//装置
                ->join("work_area_stand c", "c.id = a.work_area_stand_id", 'left')//站点
                ->where($where)
                ->order("a.create_time DESC")
                ->field([
                    'a.id', 'a.msg_name', 'a.create_time', 'a.yj_data_id', 'a.image_url', 'a.work_area_stand_id', 'a.channel_no', 'a.device_serial_id', 'a.device_serial', 'a.device_name',
                    'b.name bname',
                    'c.name cname'
                ]);
            if (!empty($param['is_export'])) {
                $list = $list_->limit(1000)->select()->toArray();
                unset($list_);
            } else {
                $list_ = $list_->paginate($page_size)->toArray();
                $list = $list_ ['data'];
            }
            foreach ($list as $key => $val) {
                //获取涉铁线路
                $list[$key]['st_line'] = WorkArea::where('id', 'IN', function ($query) use ($val) {
                    $query->name('work_area_stand')->where('id', $val['work_area_stand_id'])->field('id');
                })->value('name');
                $list[$key] ['file_url'] = VideoPlayback::where(['yj_data_id' => $val['yj_data_id']])->value('file_url');
                $list[$key] ['rtp_url_whole'] = HkDeviceSerial::where(['id' => $val['device_serial_id']])->cache(10)->value('rtp_url_whole');
            }

            //导出数据
            if (!empty($param['is_export'])) {
                //点击导出
                $arytitle = [
                    ['msg_name', '报警类型', 'A', '30'],
                    ['bname', '装置名称', 'B', '30'],
                    ['cname', '点位名称', 'C', '30'],
                    ['create_time', '时间', 'D', '30'],
                    ['image_url', '图片地址', 'E', '30']
                ];
                $filename = "导出记录" . date("Y-m-d", time());
                $list = exportExcel($filename, $arytitle, $list, '', 1); //文件名，标题数组，数据数组
            }
        } catch (\Exception $e) {
            // 验证失败 输出错误信息
            return ajaxJson(0, $e->getMessage());
        }
        return ajaxJson(1, '成功', [
            'list' => $list,
            'total' => $list_['total'] ?? 0,
            'page_size' => $page_size
        ]);
    }


    /**
     * @Apidoc\Title("入侵防御系统运行中")
     * @Apidoc\Url("/screen/railway.Stand/standAlarmStatistics")
     * @Apidoc\Method("POST")
     * @Apidoc\Returned("data", type="object", desc="对象信息",
     *    @Apidoc\Returned("id", type="int", desc="站点ID"),
     *    @Apidoc\Returned("count", type="int", desc="报警次数"),
     *    @Apidoc\Returned("name", type="string", desc="工程名称")
     * )
     */
    public function standAlarmStatistics()
    {
        $list = HkConsumerMsgWeek::alias("a")
            ->join("work_area_stand b", " b.id = a.work_area_stand_id", 'left')//装置
            ->whereDay('a.create_time')
            ->field([
                'a.id', 'count(a.id) count',
                'b.name'
            ])
            ->order("count DESC")
            ->group('a.work_area_stand_id')
            ->select()
            ->toArray();
        return ajaxJson(1, '成功', $list);
    }

    /**
     * @Apidoc\Title("喊话记录")
     * @Apidoc\Url("/screen/railway.Stand/speakLog")
     * @Apidoc\Param("work_area_stand_id",type="int",require=true, desc="工点ID")
     * @Apidoc\Param("page", type="int", desc="第几页默认第1页")
     * @Apidoc\Param("page_size", type="int", desc="每页几条默认10条")
     * @Apidoc\Method("POST")
     * @Apidoc\Returned("data", type="object", desc="对象信息",
     *    @Apidoc\Returned("id", type="int", desc="播放ID"),
     *    @Apidoc\Returned("type", type="int", desc="1上传文件 2在线录制"),
     *    @Apidoc\Returned("file", type="string", desc="文件地址"),
     *    @Apidoc\Returned("second", type="string", desc="文件秒"),
     *    @Apidoc\Returned("is_success", type="int", desc="1成功 2失败"),
     * )
     */
    public function speakLog()
    {
        try {
            $param = $this->request->param();
            Validate([
                'work_area_stand_id|工点ID' => 'require'
            ])->check($param);
            $page_size = empty($param['page_size']) ? 10 : $param['page_size'];
            $where = [];
            //指定站点查询
            if (!empty($param['work_area_stand_id'])) {
                $where[] = ['work_area_stand_id', '=', $param['work_area_stand_id']];
            }
            $list_ = IpBroadcastFile::where($where)
                ->order("a.create_time DESC")
                ->field('*')
                ->paginate($page_size)
                ->toArray();
            $list = $list_ ['data'];
        } catch (\Exception $e) {
            // 验证失败 输出错误信息
            return ajaxJson(0, $e->getMessage());
        }
        return ajaxJson(1, '成功', [
            'list' => $list,
            'total' => $list_['total'],
            'page_size' => $page_size
        ]);
    }


    /**
     * @Apidoc\Title("广播喊话")
     * @Apidoc\Url("/screen/railway.Stand/shout")
     * @Apidoc\Param("work_area_stand_id",type="int", desc="工点ID")
     * @Apidoc\Param("type", type="int", desc="1上传文件 2在线录制")
     * @Apidoc\Param("url", type="string", desc="文件地址")
     * @Apidoc\Param("hk_device_serial_id", type="int", require=true, desc="摄像头ID")
     * @Apidoc\Param("second", type="float", desc="文件秒")
     * @Apidoc\Method("POST")
     * @Apidoc\Returned("data", type="object", desc="返回说明")
     */
    public function shout()
    {
        try {
            $param = $this->request->param();
            Validate([
                // 'work_area_stand_id|工点ID' => 'require',
                'type|上传类型' => 'require',
                'url|文件地址' => 'require',
                'hk_device_serial_id|摄像头ID' => 'require'
            ])->check($param);

            //长链接调用装置播放
            //IpBroadcastService::websocketPlay($param);
            //云调用播放
            IpBroadcastService::speech($param);
            //播放记录写入
            //IpBroadcastFile::create($param);

        } catch (\Exception $e) {
            // 验证失败 输出错误信息
            return ajaxJson(0, $e->getMessage());
        }
        return ajaxJson(1, '成功');
    }

    /**
     * @Apidoc\Title("获取报警视频回放")
     * @Apidoc\Url("/screen/railway.Stand/videoPlayback")
     * @Apidoc\Param("yj_data_id",type="int",require=true, desc="报警图片列表参数")
     * @Apidoc\Method("POST")
     * @Apidoc\Returned("data", type="object", desc="对象信息",
     *    @Apidoc\Returned("id", type="int", desc="id"),
     *    @Apidoc\Returned("file_url", type="string", desc="视频网络路径")
     * )
     */
    public function videoPlayback()
    {
        try {
            $param = $this->request->param();
            Validate([
                'yj_data_id|yj_data_id' => 'require'
            ])->check($param);
            $info = VideoPlayback::where(['yj_data_id' => $param['yj_data_id']])->field(['id', 'file_url'])->find();
        } catch (\Exception $e) {
            // 验证失败 输出错误信息
            return ajaxJson(0, $e->getMessage());
        }
        return ajaxJson(1, '成功', $info);
    }


    /**
     * @Apidoc\Title("报警图片作废")
     * @Apidoc\Url("/screen/railway.Stand/cancelImg")
     * @Apidoc\Param("yj_data_id",type="int",require=true, desc="yj_data_id字段")
     * @Apidoc\Method("POST")
     * @Apidoc\Returned("data", type="object", desc="返回说明")
     */
    public function cancelImg()
    {
        try {
            $param = $this->request->param();
            Validate([
                'yj_data_id|yj_data_id' => 'require'
            ])->check($param);
            HkConsumerMsg::where(['yj_data_id' => $param['yj_data_id']])->update(['is_show' => 2]);
            HkConsumerMsgWeek::where(['yj_data_id' => $param['yj_data_id']])->update(['is_show' => 2]);
        } catch (\Exception $e) {
            // 验证失败 输出错误信息
            return ajaxJson(0, $e->getMessage());
        }
        return ajaxJson(1, '成功');
    }

    /**
     * @Apidoc\Title("获取session_id")
     * @Apidoc\Url("/screen/railway.Stand/getSessionId")
     * @Apidoc\Method("GET")
     * @Apidoc\Returned("data", type="object", desc="返回说明")
     */
    public function getSessionId()
    {
        return ajaxJson(1, '成功', cookie('PHPSESSID'));
    }
}